package com.tb.ClassSchedule;


import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

/**
 * Created by guich on 2016/8/11.
 */
public class LeftSideFragment extends LinearLayout implements View.OnClickListener{


    public LeftSideFragment(Context context, AttributeSet attrs) {
        super(context,attrs);
        LayoutInflater.from(context).inflate(R.layout.left_side_layout,this);

        View noteButton = findViewById(R.id.note_button);
        noteButton.setOnClickListener(this);
        View countDownButton = findViewById(R.id.countdown_button);
        countDownButton.setOnClickListener(this);
        View checkGradeButton = findViewById(R.id.check_grade_button);
        checkGradeButton.setOnClickListener(this);
        View importCourseButton = findViewById(R.id.import_course_button);
        importCourseButton.setOnClickListener(this);


    }


    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        intent.putExtra("function",view.getId());

        switch (view.getId()){
            case R.id.note_button:
                Toast.makeText(getContext(),"笔记本功能研发中，敬请期待。。。",Toast.LENGTH_SHORT).show();
                MainActivity.main.drawerLayout.closeDrawers();
                break;
            case R.id.countdown_button:
                Toast.makeText(getContext(),"倒计时功能研发中，敬请期待。。。",Toast.LENGTH_SHORT).show();
                MainActivity.main.drawerLayout.closeDrawers();
                break;
            case R.id.check_grade_button:
                Toast.makeText(getContext(),"查询成绩功能研发中，敬请期待。。。",Toast.LENGTH_SHORT).show();
                MainActivity.main.drawerLayout.closeDrawers();
                break;
            case R.id.import_course_button:
//                Toast.makeText(getContext(),"导入课表功能研发中，敬请期待。。。",Toast.LENGTH_SHORT).show();
                intent.setClass(getContext(),LoginActivity.class);
                getContext().startActivity(intent);
                MainActivity.main.drawerLayout.closeDrawers();
                break;
        }
    }
}
